package com.hy.mydesktop.client.component.factory;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.BaseListLoadResult;
import com.extjs.gxt.ui.client.data.BaseListLoader;
import com.extjs.gxt.ui.client.data.BaseModel;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.ListLoader;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.RpcProxy;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.hy.mydesktop.client.MyDesktop;
import com.hy.mydesktop.client.component.event.AppEvents;
import com.hy.mydesktop.client.component.meta.AbstractComponetModelEnum;
import com.hy.mydesktop.client.component.meta.ComboBoxModelEnum;
import com.hy.mydesktop.client.component.meta.ShortcutModelEnum;
import com.hy.mydesktop.client.component.meta.TextFieldModelEnum;
import com.hy.mydesktop.client.component.mvc.event.EventStructureMetaModel;
import com.hy.mydesktop.client.rpc.ServiceInvoker;
import com.hy.mydesktop.client.rpc.ServiceInvokerAsync;
import com.hy.mydesktop.client.rpc.reader.GxtToSeamServiceResultListReader;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentMetaNodeModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.ItemOfAssociateToWindow;
import com.hy.mydesktop.shared.persistence.domain.gxt.constant.ComponentMetaDataConstants;
import com.hy.mydesktop.shared.rpc.meta.GxtToSeamServiceParameter;
import com.hy.mydesktop.shared.rpc.meta.GxtToSeamServiceResult;

/**
 * 
 * <ul>
 * <li>开发作者：汤莉</li>
 * <li>设计日期：2010-8-30；时间：上午09:39:09</li>
 * <li>类型名称：ComboBoxFactory</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
public class ComboBoxFactory {
	final ServiceInvokerAsync serviceInvoker = null;

	/**
	 * 
	 * <ul>
	 * <li>方法含义：创建下拉列表框控件</li>
	 * <li>方法作者：汤莉</li>
	 * <li>编写日期：2010-8-30；时间：下午上午09:40:10</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 * @param gxtComponentMetaModel
	 * @return
	 */
	public static ComboBox<ModelData> createComboBox(GxtComponentMetaNodeModel gxtComponentMetaModel){
		return configureComboBox(gxtComponentMetaModel);
	}
	
	/**
	 * 
	 * <ul>
	 * <li>方法含义：配置下拉列表框的属性</li>
	 * <li>方法作者：汤莉</li>
	 * <li>编写日期：2010-8-30；时间：下午上午09:41:09</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 * @param gxtComponentMetaNodeModel
	 * @return
	 */
	private static ComboBox<ModelData> configureComboBox(GxtComponentMetaNodeModel gxtComponentMetaNodeModel){
		final ComboBox<ModelData> box=createDefaultcomboBox();
		AbstractComponetFactory.configureAbstractComponet(box, gxtComponentMetaNodeModel);

		if(gxtComponentMetaNodeModel.get(ShortcutModelEnum.REGISTEREVENTTYPES.name().toLowerCase())!=null){
			
			final Map<String,EventStructureMetaModel> appEventCodes = gxtComponentMetaNodeModel.get(ShortcutModelEnum.REGISTEREVENTTYPES.name().toLowerCase());
			for ( final String code : appEventCodes.keySet()) {
				Integer i = Integer.valueOf(code);
				switch (i) {
		            
		            case 2://Integer.valueOf("0002")
		            	//shortcutController.addRegisterEventType(AppEvents.DESKTOP_INIT_FOR_LOGGED_IN_USER);	
		                break;
		            case 3://Integer.valueOf("0003")
		            	
		                break;
		            case 101://Integer.valueOf("0101")
		            	//shortcutController.addRegisterEventType(AppEvents.WINDOW_ININT);
		                break;
	           		    
		            case 701:
		            	box.setData("COMBOBOX_CASCADE_LOAD", true);
		            	box.addSelectionChangedListener(new SelectionChangedListener<ModelData>() {
		        			
		        			@Override
		        			public void selectionChanged(SelectionChangedEvent<ModelData> se) {
		        				
		        				ModelData currentModelData = se.getSelectedItem();
		        				
		        				Map<String, Object> data = (Map<String, Object>)appEventCodes.get(code);
						    	  
						    	  EventStructureMetaModel eventstructuremetamodel = 
										 (EventStructureMetaModel)data.get("eventstructuremetamodel");
						    	  System.out.println("ComboBox 触发AppEvents.COMBOBOX_CASCADE_LOAD事件:"
						    			  +"控制器的Controller Id 是"+eventstructuremetamodel.getControllerId()
						    			 );
						    	  data.put("identifier", currentModelData.get("identifier"));
						    	  /**
									 * 包含的数据
									 * 级联的ComboBox的Controller的Id
									 * 当前的ComboBox的Store中被选中的元素
									 */
						    	  Dispatcher.forwardEvent(AppEvents.COMBOBOX_CASCADE_LOAD,data);
		        			}
		        		});
		            	
		            	break;
		            default:
		                break;
		        }
			}
		}
		
		
		//数据加载
		if(gxtComponentMetaNodeModel.get(AbstractComponetModelEnum.GXTTOSEAMSERVICEPARAMETERMODEL.name().toLowerCase())!=null){
			
			if (false&&box.getData("COMBOBOX_CASCADE_LOAD")!=null&&(Boolean)box.getData("COMBOBOX_CASCADE_LOAD")) {
				System.err.println("This comboBox whose id is "+box.getId()+" ,is loading data by cascade . ");
				
			} else {

				
				final ServiceInvokerAsync serviceInvoker = GWT.create(ServiceInvoker.class);
				final GxtToSeamServiceParameter gxtToSeamServiceParameter = box.getData("gxtToSeamServiceParameter");
//				final GxtToSeamServiceParameter gxtToSeamServiceParameter = new GxtToSeamServiceParameter();
				//gxtToSeamServiceParameter.setServiceComponentName("com.hy.mydesktop.server.business.PersonService");
				//gxtToSeamServiceParameter.setServiceMethodName("loadComboBoxData");
//				gxtToSeamServiceParameter.setServiceMethodName("getList2");
//				gxtToSeamServiceParameter.setServiceMethodName("getEnums");
				//BaseModel[] methodArguments2 = new BaseModel[1];
				//methodArguments2[0] = new BaseModel();
				//gxtToSeamServiceParameter.setMethodArguments(methodArguments2 );
				
				RpcProxy<GxtToSeamServiceResult> proxy = new RpcProxy<GxtToSeamServiceResult>() {

					@Override
					protected void load(Object loadConfig,
							AsyncCallback<GxtToSeamServiceResult> callback) {
						//serviceInvoker.callService(gxtToSeamServiceParameter, callback);
						serviceInvoker.callService((GxtToSeamServiceParameter)box.getData("gxtToSeamServiceParameter"), callback);
					}
				};
				
				GxtToSeamServiceResultListReader<GxtToSeamServiceResult> listReader = new GxtToSeamServiceResultListReader<GxtToSeamServiceResult>();
				ListLoader<BaseListLoadResult<ModelData>> loader = new BaseListLoader<BaseListLoadResult<ModelData>>(proxy, listReader);
				ListStore<ModelData> listStore = new ListStore<ModelData>(loader);
				
				box.setStore(listStore);
				box.setDisplayField("NAME");
				
				//listStore.getLoader().load();
				
			}
			
			
		}
		
		//数据加载
		if(gxtComponentMetaNodeModel.get(ComboBoxModelEnum.DATALOAD.name().toLowerCase())!=null){
			if (false&&box.getData("COMBOBOX_CASCADE_LOAD")!=null&&(Boolean)box.getData("COMBOBOX_CASCADE_LOAD")) {
				System.err.println("This comboBox whose id is "+box.getId()+" ,is loading data by cascade . ");
			} else {
				
				final ServiceInvokerAsync serviceInvoker = GWT.create(ServiceInvoker.class);
				final GxtToSeamServiceParameter gxtToSeamServiceParameter = box.getData("gxtToSeamServiceParameter");
//				final GxtToSeamServiceParameter gxtToSeamServiceParameter = new GxtToSeamServiceParameter();
				//gxtToSeamServiceParameter.setServiceComponentName("com.hy.mydesktop.server.business.PersonService");
				//gxtToSeamServiceParameter.setServiceMethodName("loadComboBoxData");
//				gxtToSeamServiceParameter.setServiceMethodName("getList2");
//				gxtToSeamServiceParameter.setServiceMethodName("getEnums");
				//BaseModel[] methodArguments2 = new BaseModel[1];
				//methodArguments2[0] = new BaseModel();
				//gxtToSeamServiceParameter.setMethodArguments(methodArguments2 );
				
				RpcProxy<GxtToSeamServiceResult> proxy = new RpcProxy<GxtToSeamServiceResult>() {

					@Override
					protected void load(Object loadConfig,
							AsyncCallback<GxtToSeamServiceResult> callback) {
						//serviceInvoker.callService(gxtToSeamServiceParameter, callback);
						serviceInvoker.callService((GxtToSeamServiceParameter)box.getData("gxtToSeamServiceParameter"), callback);
					}
				};
				
				GxtToSeamServiceResultListReader<GxtToSeamServiceResult> listReader = new GxtToSeamServiceResultListReader<GxtToSeamServiceResult>();
				ListLoader<BaseListLoadResult<ModelData>> loader = new BaseListLoader<BaseListLoadResult<ModelData>>(proxy, listReader);
				ListStore<ModelData> listStore = new ListStore<ModelData>(loader);
				
				box.setStore(listStore);
				box.setDisplayField("NAME");
				
				//listStore.getLoader().load();
				
			}
			
		}
		
		if(gxtComponentMetaNodeModel.get(ComboBoxModelEnum.STORE.name().toLowerCase())!=null){
			//为下拉框设置数据集
			//box.setStore((ListStore<ModelData>)gxtComponentMetaNodeModel.get(ComboBoxModelEnum.STORE.name().toLowerCase()));
		
		}
		if(gxtComponentMetaNodeModel.get(ComboBoxModelEnum.DISPLAYFIELD.name().toLowerCase())!=null){
			//设置显示的属性
			box.setDisplayField((String)gxtComponentMetaNodeModel.get(ComboBoxModelEnum.DISPLAYFIELD.name().toLowerCase()));
		
		}
		if(gxtComponentMetaNodeModel.get(ComboBoxModelEnum.EMPTYTEXT.name().toLowerCase())!=null){
			//设置空值文本
			box.setEmptyText((String)gxtComponentMetaNodeModel.get(ComboBoxModelEnum.EMPTYTEXT.name().toLowerCase()));
		
		}
		if(gxtComponentMetaNodeModel.get(ComboBoxModelEnum.FIELDLABEL.name().toLowerCase())!=null){
			//设置标签
			box.setFieldLabel((String)gxtComponentMetaNodeModel.get(ComboBoxModelEnum.FIELDLABEL.name().toLowerCase()));
		
		}
		if(gxtComponentMetaNodeModel.get(ComboBoxModelEnum.TYPEAHEAD.name().toLowerCase())!=null){
			//如有匹配的值会自动补全，并在下拉列表中显示
			box.setTypeAhead((Boolean)gxtComponentMetaNodeModel.get(ComboBoxModelEnum.TYPEAHEAD.name().toLowerCase()));
		
		}
		if(gxtComponentMetaNodeModel.get(ComboBoxModelEnum.TRIGGERACTION.name().toLowerCase())!=null){
			//当触发器领域被激活，执行这个行为
			box.setTriggerAction((TriggerAction)gxtComponentMetaNodeModel.get(ComboBoxModelEnum.TRIGGERACTION.name().toLowerCase()));
		
		}
		if(gxtComponentMetaNodeModel.get(ComboBoxModelEnum.TEMPLATE.name().toLowerCase())!=null){
			//设置模版
			box.setTemplate((String)gxtComponentMetaNodeModel.get(ComboBoxModelEnum.TEMPLATE.name().toLowerCase()));
		
		}
		if(gxtComponentMetaNodeModel.get(ComboBoxModelEnum.LOADINGTEXT.name().toLowerCase())!=null){
			//设置加载时显示的文本
			box.setLoadingText((String)gxtComponentMetaNodeModel.get(ComboBoxModelEnum.LOADINGTEXT.name().toLowerCase()));
		
		}
		/*if(gxtComponentMetaNodeModel.get(ComboBoxModelEnum.WIDTH.name().toLowerCase())!=null){
			//设置宽度
			box.setWidth((Integer)gxtComponentMetaNodeModel.get(ComboBoxModelEnum.WIDTH.name().toLowerCase()));
			
		}*/
		if(gxtComponentMetaNodeModel.get(ComboBoxModelEnum.MAXHEIGHT.name().toLowerCase())!=null){
			//设置宽度
			box.setMaxHeight((Integer)gxtComponentMetaNodeModel.get(ComboBoxModelEnum.MAXHEIGHT.name().toLowerCase()));
		
		}
		if(gxtComponentMetaNodeModel.get(ComboBoxModelEnum.NAME.name().toLowerCase())!=null){
			//设置控件名
			box.setName((String)gxtComponentMetaNodeModel.get(ComboBoxModelEnum.NAME.name().toLowerCase()));
		}
		if(gxtComponentMetaNodeModel.get(ComboBoxModelEnum.ALLOWBLANK.name().toLowerCase())!=null){
			//设置控件是否允许为空
			box.setAllowBlank((Boolean)gxtComponentMetaNodeModel.get(ComboBoxModelEnum.ALLOWBLANK.name().toLowerCase()));
		}
		
		box.setAllowBlank(true);
		return box;
		
	}
	
	/**
	 * 
	 * <ul>
	 * <li>方法含义：创建默认的下拉框</li>
	 * <li>方法作者：汤莉</li>
	 * <li>编写日期：2010-8-30；时间：下午上午09:42:27</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 * @return
	 */
	private static ComboBox<ModelData> createDefaultcomboBox(){
		ComboBox<ModelData> box=new ComboBox<ModelData>();
		box.setFieldLabel("combobox");
		box.setDisplayField("NAME");
		//ListStore<ModelData> store=new ListStore<ModelData>();
		//store.add(createStoreData());
		//box.setStore(store);
		//box.setDisplayField("name");
		return box;
	}
	
	/**
	 * 
	 * <ul>
	 * <li>方法含义：测试数据</li>
	 * <li>方法作者：汤莉</li>
	 * <li>编写日期：2010-8-31；时间：下午下午03:15:22</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 * @return
	 */
	private static List<ModelData> createStoreData()
	{
		List<ModelData> list=new ArrayList<ModelData>();
		ModelData data=new BaseModelData();
		data.set("name", "唱歌");
		list.add(data);
		
		data=new BaseModelData();
		data.set("name", "跳舞");
		list.add(data);
		
		data=new BaseModelData();
		data.set("name", "画画");
		list.add(data);
		
		return list;
	}

	public static ComboBox<ModelData> createComboBox2(
			ItemOfAssociateToWindow itemOfAssociateToWindow) {
		final ComboBox<ModelData> box=createDefaultcomboBox();
		box.setAllowBlank(true);
		GxtComponentMetaNodeModelChildrenItemsFactory.configureBaseComponentId(box, itemOfAssociateToWindow);

		if(itemOfAssociateToWindow.get(ShortcutModelEnum.REGISTEREVENTTYPES.name().toLowerCase())!=null){
			
			final Map<String,EventStructureMetaModel> appEventCodes = itemOfAssociateToWindow.get(ShortcutModelEnum.REGISTEREVENTTYPES.name().toLowerCase());
			for ( final String code : appEventCodes.keySet()) {
				Integer i = Integer.valueOf(code);
				switch (i) {
		            
		            case 2://Integer.valueOf("0002")
		                break;
		            case 3://Integer.valueOf("0003")
		                break;
		            case 101://Integer.valueOf("0101")
		            	//shortcutController.addRegisterEventType(AppEvents.WINDOW_ININT);
		                break;
	           		    
		            case 701:
		            	box.setData("COMBOBOX_CASCADE_LOAD", true);
		            	box.addSelectionChangedListener(new SelectionChangedListener<ModelData>() {
		        			
		        			@Override
		        			public void selectionChanged(SelectionChangedEvent<ModelData> se) {
		        				
		        				ModelData currentModelData = se.getSelectedItem();
		        				
		        				Map<String, Object> data = (Map<String, Object>)appEventCodes.get(code);
						    	  
						    	  EventStructureMetaModel eventstructuremetamodel = 
										 (EventStructureMetaModel)data.get("eventstructuremetamodel");
						    	  System.out.println("ComboBox 触发AppEvents.COMBOBOX_CASCADE_LOAD事件:"
						    			  +"控制器的Controller Id 是"+eventstructuremetamodel.getControllerId()
						    			 );
						    	  data.put("identifier", currentModelData.get("identifier"));
						    	  /**
									 * 包含的数据
									 * 级联的ComboBox的Controller的Id
									 * 当前的ComboBox的Store中被选中的元素
									 */
						    	  Dispatcher.forwardEvent(AppEvents.COMBOBOX_CASCADE_LOAD,data);
		        			}
		        		});
		            	
		            	break;
		            default:
		                break;
		        }
			}
		}
		
		
		//数据加载
		if(itemOfAssociateToWindow.getGxtToSeamServiceParameter()!=null){
			
			if (false&&box.getData("COMBOBOX_CASCADE_LOAD")!=null&&(Boolean)box.getData("COMBOBOX_CASCADE_LOAD")) {
				System.err.println("This comboBox whose id is "+box.getId()+" ,is loading data by cascade . ");
				
			} else {				
				final ServiceInvokerAsync serviceInvoker = Registry.get(MyDesktop.SERVICEINVOKER);
				//TODO 可以级联的加载下拉框
				final GxtToSeamServiceParameter gxtToSeamServiceParameter = itemOfAssociateToWindow.getGxtToSeamServiceParameter();
//				final GxtToSeamServiceParameter gxtToSeamServiceParameter = box.getData("gxtToSeamServiceParameter");
//				final GxtToSeamServiceParameter gxtToSeamServiceParameter = new GxtToSeamServiceParameter();
				//gxtToSeamServiceParameter.setServiceComponentName("com.hy.mydesktop.server.business.PersonService");
				//gxtToSeamServiceParameter.setServiceMethodName("loadComboBoxData");
//				gxtToSeamServiceParameter.setServiceMethodName("getList2");
//				gxtToSeamServiceParameter.setServiceMethodName("getEnums");
				//BaseModel[] methodArguments2 = new BaseModel[1];
				//methodArguments2[0] = new BaseModel();
				//gxtToSeamServiceParameter.setMethodArguments(methodArguments2 );
				
				RpcProxy<GxtToSeamServiceResult> proxy = new RpcProxy<GxtToSeamServiceResult>() {

					@Override
					protected void load(Object loadConfig,
							AsyncCallback<GxtToSeamServiceResult> callback) {
						//serviceInvoker.callService(gxtToSeamServiceParameter, callback);
//						serviceInvoker.callService((GxtToSeamServiceParameter)box.getData("gxtToSeamServiceParameter"), callback);
						serviceInvoker.callService(gxtToSeamServiceParameter, callback);
					}
				};
				
				GxtToSeamServiceResultListReader<GxtToSeamServiceResult> listReader = new GxtToSeamServiceResultListReader<GxtToSeamServiceResult>();
				ListLoader<BaseListLoadResult<ModelData>> loader = new BaseListLoader<BaseListLoadResult<ModelData>>(proxy, listReader);
				ListStore<ModelData> listStore = new ListStore<ModelData>(loader);
				
				box.setStore(listStore);
				box.setDisplayField(ComponentMetaDataConstants.DISPLAY_FIELD);
//				box.setDisplayField("NAME");
				//listStore.getLoader().load();
			}
			
		}
		
		//数据加载
		if(itemOfAssociateToWindow.get(ComboBoxModelEnum.DATALOAD.name().toLowerCase())!=null){
			if (false&&box.getData("COMBOBOX_CASCADE_LOAD")!=null&&(Boolean)box.getData("COMBOBOX_CASCADE_LOAD")) {
				System.err.println("This comboBox whose id is "+box.getId()+" ,is loading data by cascade . ");
			} else {
				
				final ServiceInvokerAsync serviceInvoker = Registry.get(MyDesktop.SERVICEINVOKER);
				final GxtToSeamServiceParameter gxtToSeamServiceParameter = box.getData("gxtToSeamServiceParameter");
				
				RpcProxy<GxtToSeamServiceResult> proxy = new RpcProxy<GxtToSeamServiceResult>() {

					@Override
					protected void load(Object loadConfig,
							AsyncCallback<GxtToSeamServiceResult> callback) {
						//serviceInvoker.callService(gxtToSeamServiceParameter, callback);
						serviceInvoker.callService((GxtToSeamServiceParameter)box.getData("gxtToSeamServiceParameter"), callback);
					}
				};
				
				GxtToSeamServiceResultListReader<GxtToSeamServiceResult> listReader = new GxtToSeamServiceResultListReader<GxtToSeamServiceResult>();
				ListLoader<BaseListLoadResult<ModelData>> loader = new BaseListLoader<BaseListLoadResult<ModelData>>(proxy, listReader);
				ListStore<ModelData> listStore = new ListStore<ModelData>(loader);
				box.setStore(listStore);
				box.setDisplayField("NAME");
				//listStore.getLoader().load();
			}
			
		}
		
		if(itemOfAssociateToWindow.get(ComboBoxModelEnum.STORE.name().toLowerCase())!=null){
			//为下拉框设置数据集
			//box.setStore((ListStore<ModelData>)gxtComponentMetaNodeModel.get(ComboBoxModelEnum.STORE.name().toLowerCase()));
		
		}
		if(itemOfAssociateToWindow.get(ComboBoxModelEnum.DISPLAYFIELD.name().toLowerCase())!=null){
			//设置显示的属性
			box.setDisplayField((String)itemOfAssociateToWindow.get(ComboBoxModelEnum.DISPLAYFIELD.name().toLowerCase()));
		
		}
		if(itemOfAssociateToWindow.get(ComboBoxModelEnum.EMPTYTEXT.name().toLowerCase())!=null){
			//设置空值文本
			box.setEmptyText((String)itemOfAssociateToWindow.get(ComboBoxModelEnum.EMPTYTEXT.name().toLowerCase()));
		
		}
		if(itemOfAssociateToWindow.get(ComboBoxModelEnum.FIELDLABEL.name().toLowerCase())!=null){
			//设置标签
			box.setFieldLabel((String)itemOfAssociateToWindow.get(ComboBoxModelEnum.FIELDLABEL.name().toLowerCase()));
		
		}
		if(itemOfAssociateToWindow.get(ComboBoxModelEnum.TYPEAHEAD.name().toLowerCase())!=null){
			//如有匹配的值会自动补全，并在下拉列表中显示
			box.setTypeAhead((Boolean)itemOfAssociateToWindow.get(ComboBoxModelEnum.TYPEAHEAD.name().toLowerCase()));
		
		}
		if(itemOfAssociateToWindow.get(ComboBoxModelEnum.TRIGGERACTION.name().toLowerCase())!=null){
			//当触发器领域被激活，执行这个行为
			box.setTriggerAction((TriggerAction)itemOfAssociateToWindow.get(ComboBoxModelEnum.TRIGGERACTION.name().toLowerCase()));
		
		}
		if(itemOfAssociateToWindow.get(ComboBoxModelEnum.TEMPLATE.name().toLowerCase())!=null){
			//设置模版
			box.setTemplate((String)itemOfAssociateToWindow.get(ComboBoxModelEnum.TEMPLATE.name().toLowerCase()));
		
		}
		if(itemOfAssociateToWindow.get(ComboBoxModelEnum.LOADINGTEXT.name().toLowerCase())!=null){
			//设置加载时显示的文本
			box.setLoadingText((String)itemOfAssociateToWindow.get(ComboBoxModelEnum.LOADINGTEXT.name().toLowerCase()));
		
		}
		if(itemOfAssociateToWindow.get(ComboBoxModelEnum.WIDTH.name().toLowerCase())!=null){
			//设置宽度
			box.setWidth((Integer)itemOfAssociateToWindow.get(ComboBoxModelEnum.WIDTH.name().toLowerCase()));
			
		}
		if(itemOfAssociateToWindow.get(ComboBoxModelEnum.MAXHEIGHT.name().toLowerCase())!=null){
			//设置宽度
			box.setMaxHeight((Integer)itemOfAssociateToWindow.get(ComboBoxModelEnum.MAXHEIGHT.name().toLowerCase()));
		
		}
		if(itemOfAssociateToWindow.get(ComboBoxModelEnum.NAME.name().toLowerCase())!=null){
			//设置控件名
			box.setName((String)itemOfAssociateToWindow.get(ComboBoxModelEnum.NAME.name().toLowerCase()));
		}
		if(itemOfAssociateToWindow.get(ComboBoxModelEnum.ALLOWBLANK.name().toLowerCase())!=null){
			//设置控件是否允许为空
			box.setAllowBlank((Boolean)itemOfAssociateToWindow.get(ComboBoxModelEnum.ALLOWBLANK.name().toLowerCase()));
		}
		
		return box;
	}
}
